package com.zygk.library.util;

import com.zygk.library.model.EventBusEvent;
import org.greenrobot.eventbus.EventBus;

/**
 * Created by Wikison on 2018/5/29.
 */
public class EventBusUtil {
  public static void register(Object subscriber) {
    if (!EventBus.getDefault().isRegistered(subscriber)) {
      EventBus.getDefault().register(subscriber);
    }
  }

  public static void unregister(Object subscriber) {
    if (EventBus.getDefault().isRegistered(subscriber)) {
      EventBus.getDefault().unregister(subscriber);
    }
  }

  public static void sendEvent(EventBusEvent event) {
    EventBus.getDefault().post(event);
  }

  public static void sendStickyEvent(EventBusEvent event) {
    EventBus.getDefault().postSticky(event);
  }
}
